﻿using System.Linq;

using DAL;
using System.Data;
namespace BLL
{
    public abstract class BaseRepository
    {
        public string Start_Time { get { return "Start_Time"; } }
        public string End_Time { get { return "End_Time"; } }
        public string Start_Int { get { return "Start_Int"; } }
        public string End_Int { get { return "End_Int"; } }

        /// <summary>
        /// 确定删除一个对象，调用Save方法
        /// </summary>
        /// <param name="id">一条数据的主键</param>
        /// <returns></returns>    
        public int Delete(string id)
        {
            using (SysEntities db = new SysEntities())
            {
                this.Delete(db, id);
                return Save(db);
            }
        }
        /// <summary>
        /// 删除一个对象
        /// </summary>
        /// <param name="db">实体数据</param>
        /// <param name="id">一条数据的主键</param>
        public abstract void Delete(SysEntities db, string id);
        /// <summary>
        /// 删除对象集合
        /// </summary>
        /// <param name="db">实体数据</param>
        /// <param name="deleteCollection">主键的集合</param>
        public abstract void Delete(SysEntities db, string[] deleteCollection);
        /// <summary>
        /// 提交保存，持久化到数据库
        /// </summary>
        /// <param name="db">实体数据</param>
        /// <returns>受影响行数</returns>
        public int Save(SysEntities db)
        {
            int i = db.SaveChanges();
            return i;
        }
    }
}
